﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CSharp.Libs.Koc;
using CSharp.Libs.WPF.UserControls;
using CSharp.Libs.Misc;
using CSharp.Libs.Koc.KernelModels;

namespace KocInformant
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Kernel _KRNL = new Kernel();
        private DataLogSQLite _DL = new DataLogSQLite();

        public MainWindow()
        {
            InitializeComponent();

            //init message logging
            //messageLoggingTextBox1.InitViewModel(_KRNL.ML);

            //init informant contorol
            kocInformantControl1.InitializeVM(_KRNL);

            //Set logging switches
            //_KRNL.LoggingEnabled = true;
            //_KRNL.LogPostHandler = true;
            //_KRNL.LogTrafficMonitor = true;
            _DL.InitDb();
            _KRNL.TM.SessionReceived += new TrafficMonitor.SessionReceivedEventHandler(TM_SessionReceived);
        }

        void TM_SessionReceived(object sender, SessionReceidedEventArgs srea)
        {
            _DL.SaveDataLogItem(new DataLogItem
            {
                Level = "information",
                Category = "session_received",
                LogTime = DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss"),
                Tags = "Session;Request;Response",
                Message = "request|" + srea.Request.Trim() + "|response|" + srea.Response.Trim()
            });
        }

        //This is Test1. check in to diskstation then svnsync to code.google.com
        //This is Test2. check in to code.google.com then syncsvn to diskstation
    }
}
